
const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property
    text: string = 'hello';

    // LIFE-CYCLE CALLBACKS:
    onKeyDown(event){
        //console.log("onKeyDown:"+event.keyCode)
        //cc.macro.KEY;
    }

    onKeyUp(event:cc.Event.EventKeyboard){
        //console.log("onKeyUp:"+event.keyCode)
    }

    mouseMove(event:cc.Event.EventMouse){
        //console.log("mouseMove:"+event.getLocation())
    }

    onLoad () {
        cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyDown, this);
        cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyUp, this);       
        //启动鼠标监听事件
        this.node.on(cc.Node.EventType.MOUSE_MOVE,this.mouseMove,this);

    }

    start () {

    }

    // update (dt) {}

    onDestroy () {
        cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
        cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
        this.node.off(cc.Node.EventType.MOUSE_MOVE,this.mouseMove,this);
    }
}
